package com.ht.medicaltreatment.view

import android.app.Dialog
import android.content.Context
import android.view.LayoutInflater
import com.ht.medicaltreatment.R
import com.xgst.lib.utils.ScreenUtils
import kotlinx.android.synthetic.main.dialog_remark_layout.etContent
import kotlinx.android.synthetic.main.dialog_remark_layout.tvCancel
import kotlinx.android.synthetic.main.dialog_replace_layout.tvSubmit

//输入内容
class InputEditTextDialog(context: Context) : Dialog(context, R.style.dialogStyle) {

    private lateinit var mClick:(String) -> Unit

    init {
        val view =
            LayoutInflater.from(context).inflate(R.layout.dialog_remark_layout, null, false)
        setContentView(view)
        val attributes = window!!.attributes
        attributes.width= ScreenUtils.dp2px(context,300)
        //attributes.height= ScreenUtils.dp2px(context,300)
        window!!.attributes = attributes
        setCancelable(true)
        tvSubmit.setOnClickListener {
            if(etContent.text == null){
                return@setOnClickListener
            }
            mClick(etContent.text.toString())
            dismiss()
        }
        tvCancel.setOnClickListener {
            dismiss()
        }
    }

    fun showDialog(onClick:(String)->Unit){
        mClick = onClick
        show()
    }

}